﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaskScheduler;

namespace TaskSchedulerTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Scheduler scheduler = new Scheduler();

            SimpleTrigger simpleTrigger = new SimpleTrigger(2, 3);
            CronTrigger cronTrigger = new CronTrigger("0/5 * * ? * MON-FRI");

            scheduler.AddJob("job1", cronTrigger, (sch, trigger) =>
             {
                 Console.WriteLine("cronTrigger触发，工作日每隔5秒");
             });

            scheduler.AddJob("job2", simpleTrigger, (sch, trigger) =>
             {
                 Console.WriteLine("simpleTrigger触发，每隔两秒，本来要执行三次的");

                 Console.WriteLine("终结job2");
                 sch.RemoveJob("job2");
                 Console.WriteLine("动态加入jobnew");
                 scheduler.AddJob("jobnew", new SimpleTrigger(2, 2), (s, t) =>
                 {
                     Console.WriteLine("jobnew代替job2，执行后两次");
                 });
             });

            scheduler.Start();
            Console.ReadLine();
        }
    }
}
